import time


def metric(fn):
    def clock(*args, **kwargs):
        fn.start_time = time.time()
        run = fn(*args, **kwargs)
        fn.end_time = time.time()
        print('耗时：{:.9f}s'.format(fn.end_time - fn.start_time))
        return run

    return clock


# 测试
@metric
def one(x, y):
    time.sleep(1)
    print(x, y)


@metric
def two(x, y, z):
    time.sleep(1)
    print(x, y, z)


@metric
def three(x, y, z, k):
    time.sleep(1)
    print(x, y, z, k)


o = one(1, 888)
t = two(8, 4, 9)
t1 = three(1, 88, 954, 10000)

print(one)
print(two)
print(three)
